#ifndef COLOR_HH_
#   define COLOR_HH_


// some defined Colors
# define COLOR_SOLID_WHITE	255, 255, 255, 0
# define COLOR_SOLID_BLACK	0,   0,   0,   0
# define COLOR_SOLID_RED	255, 0,   0,   0
# define COLOR_SOLID_GREEN	0,   255, 0,   0
# define COLOR_SOLID_BLUE	0,   0,   255, 0


/** Color class
 ** including Transparency as 4th param
 ** each colors and alpha \in [| 0; 255 |] (coded on chars)
 ** where 0 means opaque and 255 fully transparent
 */
class Color
{
public:
  // ---------- Ctors / Dtor ----------

  /** default Ctor
   ** in Debug, sets RGB values to 0, 255, 255, 0 (cyan color)
   ** otherwise, sets to opaque black
   **/
  Color();

  /** allows to set Red, Green, Blue values (transparency will be set to 0) */
  Color(char red, char green, char blue);

  /** Sets RGB to user's color */
  Color(char red, char green, char blue, char alpha);

  ~Color();


  // ---------- Getters ----------
  char r();
  char g();
  char b();
  char a();

  // ---------- Setters ----------
  void setR(char red);
  void setG(char green);
  void setB(char blue);
  void setA(char alpha);

  void setColor(char red, char green, char blue, char alpha);

  void setColor(char red, char green, char blue);


  // ---------- Alpha Alterations ----------

  /** fade effect
   ** \param timeToFade: time to make the Color 'disappear'
   ** 'disappear' means make alpha reach 255, incrementing alpha over time
   **   (from current value to 255 in timeToFade seconds)
   **
   ** this method could be usefull to make bloodstains disappear
   */
  void fade(float timeToFade);


  /** color reinforcement effect
   ** \param timeToShow: time to make the Color 'appear'
   ** 'appear' means make alpha reach 0, decrementing alpha over time
   **   (from current value to 0 in timeToShow seconds)
   **
   ** this method could be usefull to make subtitles appear
   */
  void show(float timeToShow);


  /** fade or reinforcement effect, according to \param alpha and a_ values
   ** \param timeToReachAlpha: time to make the Color reach \param alpha
   ** \param alpha: alpha value to reach after \param timeToReachAlpha seconds
   ** incrementing or decrementing alpha over time
   **   (from current value to \param alpha in timeToFade seconds)
   */
  void alterAlpha(float timeToReachAlpha, char alpha);


  // overload these functions to allow them to close concurrents threads to take the lock


private:
  char _r; /// red value
  char _g; /// green value
  char _b; /// blue value
  char _a; /// alpha value (transparency)
  bool _alphaLock; /// true if a thread already have the alpha
};

#endif /* !COLOR_HH_ */
